#coding:utf8
#
# Author: CMGS
# Created on 2010-10-10
#

from libs import klive as _klive
from libs.rpc import rpc as _rpc
from common import defcode as _defcode
from common import config as _config

def share(token, fileId, sharers, writable):
    mailContent =  _config.THIS_SERVER + '/cooper/wowtext.html?fileId=%s' % fileId 
    params = {'token': token, 'fileId': fileId, 'sharers': sharers, 'writable': str(writable), 'sendMail': 'true', 'mailContent': mailContent}
    ret = _klive.getApiData('asmShare', params, 2)
    if ret != {}:
        return _rpc.toJson({'code': _defcode.OPT_OK})
    return _rpc.toJson({'code': _defcode.OPT_FAILED, 'reason': ret})
